package com.example.drawscreen;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends Activity {
	
	 Button startstopbutton,setting_button,share_button;
	 int modeSelected = 0; 															//1 start : 0 stop
	 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.home);
        
        startstopbutton = (Button) findViewById(R.id.startstopbutton);
        setting_button = (Button) findViewById(R.id.setting_button);
        share_button = (Button) findViewById(R.id.share_button);
        
        startstopbutton.setOnClickListener(new OnClickListener() {			
			@Override
			public void onClick(View arg0) {
				if(modeSelected == 0){ 
					startService();
					modeSelected = 1;
					startstopbutton.setText(R.string.stop_button);
				}else{
					stopService();
					modeSelected = 0;
					startstopbutton.setText(R.string.start_button);					
				}
			}
		});

        setting_button.setOnClickListener(new OnClickListener() {			
			@Override
			public void onClick(View arg0) {
				Intent intent = new Intent(getApplicationContext(), SettingActivity.class);
				intent.putExtra("modeSelected", modeSelected);
				startActivity(intent);
			}
		});
        
    }
    
    public void startService() {
    	startService(new Intent(this, FingersService.class));
     }
    public void stopService() {
        stopService(new Intent(this, FingersService.class));
     }
    
    @Override
    public boolean onTouchEvent(MotionEvent MEvent) {
    	if(MEvent.getAction() == 261) {
        	Log.d("QUYYYYYYYYYYYYYYYYY", "Co Event 2 ngon o local " + MEvent.getAction());
    	}
    	if(MEvent.getAction() == 517) {
        	Log.d("QUYYYYYYYYYYYYYYYYY", "Co Event 3 ngon o local " + MEvent.getAction());
    	}
    	if(MEvent.getAction() == 773) {
        	Log.d("QUYYYYYYYYYYYYYYYYY", "Co Event 4 ngon o local " + MEvent.getAction());
    	}
    	return false;
    }
    
}
